class ConvertBean:
    def __init__(self, className, parameters):
        self.__className = className
        self.__parameters = parameters

    def convert(self):
        classStr = "class {0}:\n    def __init__(self,{1}):\n{2}\n\n{3}\n{4}"
        propertyStr = "@property"
        setterStr = ".setter"
        initParms = []
        initParmsAss = []
        initParmsGetter = []
        initParmsSetter = []
        size = len(self.__parameters)
        for i in range(size):
            __parm = self.__parameters[i]
            initParms.append(__parm)
            initParmsAss.append("        self.__" + __parm + " = " + __parm)
            initParmsGetter.append(
                "    " + propertyStr + "\n    def " + __parm + "(self):\n        return self.__" + __parm + "\n")
            initParmsSetter.append(
                "    @" + __parm + setterStr + "\n    def " + __parm + "(self, " + __parm + "):\n        self.__" + __parm + " = " + __parm + "\n")
        __initParmsForInitParms = ",".join(initParms)  # 填充构造函数参数
        __initParmsForAssignment = "\n".join(initParmsAss)  # 参数赋值
        __initParmsForGetter = "\n".join(initParmsGetter)  # 生成getter
        __initParmsForSetter = "\n".join(initParmsSetter)  # 生成setter

        print(classStr.format(self.__className, __initParmsForInitParms, __initParmsForAssignment, __initParmsForGetter,
                              __initParmsForSetter))


if __name__ == '__main__':
    bean = ConvertBean("CaipuInfoDto",
                       ["caipu_info_id",
                        "caipu_title",
                        "caipu_third_source_id",
                        "caipu_main_ingredients_json",
                        "caipu_others_ingredients_json",
                        "caipu_intro",
                        "caipu_tips",
                        "caipu_tech",
                        "caipu_steps",
                        "caipu_imgs"

                        ])
    bean.convert()
